<template>
  <!-- 流行、新款、精选标题 -->
  <div class="tabControl">
    <div v-for="(item, index) in titles" :key="item" @click="updateIndex(index)">
      <span :class="[i=== index ? 'active' :'']">{{item}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TabControl",
    props: {
      titles: {
        type: Array,
        default(){
          return []
        }
      }
    },
    data(){
      return {
        i: 0
      }
    },
    methods: {
      updateIndex(i){
        this.i = i;
        this.$emit('clickGood', i)
      }
    }
  }
</script>

<style scoped>
  .tabControl{
    display: flex;
    font-size: 20px;
  }
  .tabControl div{
    flex: 1;
    text-align: center;
    height: 40px;
    line-height: 40px;
  }
  .tabControl div span{
    padding: 5px;
  }
  .active{
    color: var(--color-high-text);
    border-bottom: 1px solid var(--color-high-text);
  }
</style>
